//
//  CKImage.h
//  ConnectionKit
//
//  Created by Matthias Plappert on 13.06.09.
//  Copyright 2009 phapswebsolutions. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <UIKit/UIKit.h>

#import "CKImageDelegate.h"

#define kCKImageUnsupportedMIMEType 4

typedef enum {
	CKImageStatusDefault,
	CKImageStatusLoading,
	CKImageStatusDidLoad,
	CKImageStatusNotFound
} CKImageStatus;

@interface CKImage : NSObject {
	CGSize size;
	NSString *URL;
	UIImage *image;
	UIImage *errorImage;
	BOOL cache;
	CKImageStatus status;
	
	id <CKImageDelegate> delegate;
	
	NSMutableData *_data;
	NSURLConnection *_connection;
}

@property (nonatomic, assign) CGSize size;
@property (nonatomic, copy) NSString *URL;
@property (nonatomic, retain) UIImage *image;
@property (nonatomic, retain) UIImage *errorImage;
@property (nonatomic, assign) BOOL cache;
@property (nonatomic, readonly) CKImageStatus status;

@property (nonatomic, assign) id <CKImageDelegate> delegate;

- (void)didReceiveMemoryWarning;
- (void)cancel;

- (void)load:(BOOL)synchronous;
- (BOOL)checkResponse:(NSURLResponse *)response;

@end
